<?php
// 显示所有错误
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// 初始化会话
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

// 检查当前状态
$isLoggedIn = isset($_SESSION['admin_user_id']);
$username = $_SESSION['admin_username'] ?? '未登录';
$userId = $_SESSION['admin_user_id'] ?? 'NULL';

// 输出JSON格式的会话信息
$data = [
    'isLoggedIn' => $isLoggedIn,
    'username' => $username,
    'userId' => $userId,
    'sessionId' => session_id(),
    'sessionData' => $_SESSION,
    'cookies' => $_COOKIE,
    'phpVersion' => phpversion(),
    'sessionStatus' => session_status(),
    'sessionPath' => session_save_path(),
    'currentPage' => basename($_SERVER['PHP_SELF']),
    'serverInfo' => [
        'host' => $_SERVER['HTTP_HOST'] ?? 'unknown',
        'userAgent' => $_SERVER['HTTP_USER_AGENT'] ?? 'unknown',
        'requestTime' => $_SERVER['REQUEST_TIME'] ?? 'unknown',
        'documentRoot' => $_SERVER['DOCUMENT_ROOT'] ?? 'unknown',
    ]
];

header('Content-Type: application/json');
echo json_encode($data, JSON_PRETTY_PRINT); 